IF EXISTS (SELECT * FROM sysobjects WHERE type = 'U' AND name = 'GROUP2USER')
BEGIN
    DROP TABLE [dbo].[GROUP2USER]
END

GO

CREATE TABLE [dbo].[GROUP2USER] ( 
	[ID]			INT IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
	[GROUP_ID]      INT         NOT NULL,
    [USER_ID]       INT         NOT NULL

    CONSTRAINT [PK_GROUP2USER_ID] PRIMARY KEY CLUSTERED ( 
        [ID] 
    ) ON [PRIMARY],
    
    CONSTRAINT [FK_GROUP2USER_GROUP_ID] FOREIGN KEY ( 
        [GROUP_ID]
    ) REFERENCES [dbo].[EDUCATION_GROUP] (
        [ID]
    ),
    
    CONSTRAINT [FK_GROUP2USER_USER_ID] FOREIGN KEY ( 
        [USER_ID]
    ) REFERENCES [dbo].[USER] (
        [ID]
    )
    
) ON [PRIMARY] 

CREATE INDEX [IDX_GROUP2USER_GROUP_ID_USER_ID] on [dbo].[GROUP2USER] ([GROUP_ID],[USER_ID]) 

GO